<template>
	<div>
    <div>
      <el-row>
        <el-col :offset="2" :span="4">
          <el-input v-model="studentname" placeholder="请输入账号搜索"></el-input>
        </el-col>
        <el-col :offset="1" :span="6">
          <el-button type="primary" @click="selectbyname(studentname)">搜索</el-button>
        </el-col>
        <el-col :offset="3" :span="6">
          <el-button
          @click="exportLog()" type="primary">导出excel</el-button>
        </el-col>
        <!-- <el-col :span="6"><div class="grid-content bg-purple-light">4</div></el-col> -->
      </el-row>
    </div>

    <el-col>
      &nbsp;
    </el-col>

		    <el-table
            :data="studentData"
            style="width: 100%">
            <el-table-column
            label="id"
            width="180">
            <template slot-scope="scope">
                <!-- <i class="el-icon-time"></i> -->
                <span style="margin-left: 10px">{{ scope.row.id }}</span>
            </template>
            </el-table-column>
            <el-table-column
            label="账号"
            width="180">
            <template slot-scope="scope">
                <span style="margin-left: 10px">{{ scope.row.username }}</span>
            </template>
            </el-table-column>
            <el-table-column
            label="模块"
            width="180">
            <template slot-scope="scope">
                <span style="margin-left: 10px">{{ scope.row.module }}</span>
            </template>
            </el-table-column>
            <el-table-column
            label="类型"
            width="180">
            <template slot-scope="scope">
                <span style="margin-left: 10px">{{ scope.row.type }}</span>
            </template>
            </el-table-column>
            <el-table-column
            label="操作详情"
            width="180">
            <template slot-scope="scope">
                <span style="margin-left: 10px">{{ scope.row.detail }}</span>
            </template>
            </el-table-column>
            <el-table-column
            label="操作时间"
            width="180">
            <template slot-scope="scope">
                <span style="margin-left: 10px">{{ scope.row.date }}</span>
            </template>
            </el-table-column>
            <el-table-column
            label=""
            width="180">
            <template slot-scope="scope">
                <!-- <span style="margin-left: 10px">{{ scope.row.date }}</span> -->
            </template>
            </el-table-column>
     
            <!-- <el-table-column
            label="姓名"
            width="180">
            <template slot-scope="scope">
                <el-popover trigger="hover" placement="top">
                <p>姓名: {{ scope.row.name }}</p>
                <p>住址: {{ scope.row.phone }}</p>
                <div slot="reference" class="name-wrapper">
                    <el-tag size="medium">{{ scope.row.name }}</el-tag>
                </div>
                </el-popover>
            </template>
            </el-table-column> -->


            <!-- <el-table-column label="操作">
            <template slot-scope="scope">
                <el-button
                size="mini"
                @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
                <el-button
                size="mini"
                type="danger"
                @click="handleDelete(scope.$index, scope.row)">删除</el-button>
            </template>
            </el-table-column> -->
        </el-table>
        <el-row>
          <el-col :offset="16" :span="8">
            <div class="block">
              <el-pagination
                layout="prev, pager, next"
                @current-change="handleCurrentChange"
                :total="1000">
              </el-pagination>
            </div>
          </el-col>
        </el-row>
        
	</div>
</template>



<script>
	import axios from 'axios';

  export default {
    data() {
      return {
        studentname:"",
		    studentData:[],
        formdata:{},
        dialogVisible:false,
        requesturl:"http://162.14.107.118:8086/",
      }
    },
    methods: {  

      handleCurrentChange(val) {
            axios.get(this.requesturl+ `PC/getLogBypage/${val-1}`).then(res=>{
              if(res.data.status)
                this.studentData=res.data.data
              else 
                this.$message('没有这一页的数据');

            })
      },
      exportLog(){
        window.open(this.requesturl+ "PC/exportExcelLogs")
      },
      
      //根据学生姓名搜索
      selectbyname(studentname){
        axios.get(this.requesturl+ `PC/getLogByUsername/${studentname}`).then(res=>{
            if(res.data.status){
                this.studentData=res.data.data
            }
            else {
                this.$message('查询失败,没有这个用户');
            }
               
        })

      },
	
		
		//获得所有学生信息   
		getStudentInfo(){
			axios.get(this.requesturl+"PC/getUserLogs").then(res=>{
				this.studentData=res.data.data;

			})
		}
    },
	created(){
		this.getStudentInfo();
	},

  }
</script>
